package com.miplus.ccrm.core.api.dify.model;

import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * 流式调用响应.
 */
@Data
public class StreamResponse implements Serializable {
    private static final long serialVersionUID = 1L;

    // 通用字段
    private String event;
    private String message_id;
    private String conversation_id;
    private Long created_at;

    // message事件特有字段
    private String answer;

    // message_end事件特有字段
    private String id;
    private Metadata metadata;

    // tts_message事件特有字段
    private String task_id;
    private String audio;

    @Data
    public static class Metadata {
        private Usage usage;
        private List<RetrieverResource> retriever_resources;
    }

    @Data
    public static class Usage {
        private Integer prompt_tokens;
        private String prompt_unit_price;
        private String prompt_price_unit;
        private String prompt_price;
        private Integer completion_tokens;
        private String completion_unit_price;
        private String completion_price_unit;
        private String completion_price;
        private Integer total_tokens;
        private String total_price;
        private String currency;
        private Double latency;
    }

    @Data
    public static class RetrieverResource {
        private Integer position;
        private String dataset_id;
        private String dataset_name;
        private String document_id;
        private String document_name;
        private String segment_id;
        private Double score;
        private String content;
    }
}

